home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-11 | 3.9 KB | 141 lines | [TEXT/CWIE] |
- // TNetworkAcceptor.h - Macintosh OpenTransport Network Acceptor class object
- //
- // Apple Macintosh Developer Technical Support
- // Written by: Vinne Moscaritolo
- //
- // Copyright (work in progress) Apple Computer, Inc All rights reserved.
- //
- // You may incorporate this sample code into your applications without
- // restriction, though the sample code has been provided "AS IS" and the
- // responsibility for its operation is 100% yours. However, what you are
- // not permitted to do is to redistribute the source as "DSC Sample Code"
- // after having made changes. If you're going to re-distribute the source,
- // we require that you make it clear in the source that the code was
- // descended from Apple Sample Code, but that you've made changes.
- //
-
- #ifndef _H_TNETWORKACCEPTOR
- #define _H_TNETWORKACCEPTOR
-
- #include "TNetworkEventHandler.h"
- #include "TNetworkEndpointDescriptor.h"
- #include "TNetworkSession.h"
- #include "TGMT.h"
-
- #define kSessionStackSpace 8192
-
- class TSessionPrefs
- {
- public:
- TSessionPrefs():
- fMaxFreeSessions(4),
- fBuildSessions(4),
- fMaxOutStanding(256)
- {};
-
- short fMaxFreeSessions; // max Free Sessions cached
- short fBuildSessions; // Free Session to prebuild
- short fMaxOutStanding; // max outstanding connections.
- };
-
- struct TAcceptorInfo
- {
- TAcceptorInfo():
- fActiveSessions(0),
- fFreeSessions(0),
- fAcceptedSessions(0),
- fRejectedSessions(0),
- fDisconSessions(0),
- fUpTime(0){};
-
- short fActiveSessions ;
- short fFreeSessions;
- int fAcceptedSessions;
- int fRejectedSessions;
- int fDisconSessions;
- unsigned long fUpTime;
-
- };
-
- typedef struct TAcceptorInfo TAcceptorInfo;
-
-
- //
- // TNetworkAcceptor - OpenTransport Network Acceptor class
- //
- class TNetworkAcceptor : public TNetworkEventHandler
- {
-
- public:
- enum { kSessionAvailable = (OTEventCode) kPRIVATEEVENT,
- kOtherEvent};
-
-
- // CONSTRUCTORS AND DESTRUCTORS
- public:
- TNetworkAcceptor(char* ServerName = 0):
- fEPD(NULL),
- fEndPoint(kOTInvalidEndpointRef),
- fPending(kNonePending),
- fLocalAddress(NULL)
- {};
-
- virtual ~TNetworkAcceptor();
-
- // HIGH LEVEL FUNCTIONS
- public:
- virtual void Open(TNetworkEndpointDescriptor*);
-
- // ACCESSORS
- public:
- TNetworkEndpointDescriptor* GetEPD() {return fEPD; };
- Boolean GetStats( TAcceptorInfo* );
-
- // ABSTRACT FUNCTIONS
- protected:
- virtual TNetworkSession* SessionFactory() = 0;
-
- // FUNCTIONS FROM TNetworkEventHandler
- private:
- void HandleEvent(TNetworkEvent* );
-
- // EVENT MANGEMENT FUNCTIONS
- private:
- void EventOpenComplete (TNetworkEvent* );
- void EventBindComplete (TNetworkEvent* );
- void EventListen (TNetworkEvent* );
- void EventAcceptComplete (TNetworkEvent* );
- void EventDisconnect (TNetworkEvent* );
- void EventDisconnectComplete(TNetworkEvent* );
- void EventUnbindComplete (TNetworkEvent* );
- void EventSessionAvailable (TNetworkEvent* ); // private event
- void EventOther (TNetworkEvent* ); // Debug event
-
- // OPEN TRANSPORT CALLBACK
- static pascal void NotifyProc (TNetworkAcceptor* , OTEventCode , OTResult , void* );
-
- // PRIVATE FUNCTIONS
- void DoListen ( TNetworkSession *);
-
- // PRIVATE FIELDS
- private:
- enum {kUnBound = -1, kNonePending = 0} ;
-
- TNetworkEndpointDescriptor* fEPD; // Endpoint descriptor
- EndpointRef fEndPoint; // OT Endpoint
- TEndpointInfo fInfo; // Endpoint information
- TList fActiveSessions; // list of active sessions
- TList fFreeSessions; // list of cached free sessions
- TAddr* fLocalAddress; // Address bound to
- TBind fReqBind; // Requested Address
- TBind fRetBind; // What we really gt
- int fPending; // listen events pending.
- TSessionPrefs fPrefs; // Session Preferences
- TAcceptorInfo fStats; // Usage Statisics
- TGmt fStartTime; // Time Server Came Up
-
- };
-
-
- #endif
-